﻿using System.Collections.Generic;

using FakeItEasy;

using FluentAssertions;

using NewModel.Accounting.Persistence;
using NewModel.UnitTests.Accounting.Persistence._Samples_;

using NUnit.Framework;

namespace NewModel.UnitTests.Accounting.Persistence
{
    [TestFixture]
    public sealed class TestBatchesOperations
    {
        static readonly BatchDescriptor sThursday = BatchDescriptors.Thursday;
        static readonly BatchDescriptor sFriday = BatchDescriptors.Friday;
        static readonly BatchDescriptor sSaturday = BatchDescriptors.Saturday;
        static readonly BatchDescriptor sSunday = BatchDescriptors.Sunday;
        static readonly Ledger sLedger = new Ledger { Batches = 
            new List<BatchDescriptor> { sThursday, sFriday, sSaturday, sSunday }
        };
        static readonly Batch sSaturdayBatch = new Batch();
        static readonly Batch sSundayBatch = new Batch();

        BatchesOperations mUnderTest;
        IBatchLoader mBatchLoader;

        [SetUp]
        public void SetUp()
        {
            mBatchLoader = A.Fake<IBatchLoader>();
            mUnderTest = new BatchesOperations(sLedger, mBatchLoader);
            A.CallTo(() => mBatchLoader.Load(sLedger, sSaturday)).Returns(sSaturdayBatch);
            A.CallTo(() => mBatchLoader.Load(sLedger, sSunday)).Returns(sSundayBatch);
        }

        [Test]
        public void GetBatches_Should_Load_Correct_Batches()
        {
            mUnderTest.GetBatches(Intervals.July).Should()
                .Equal(sSaturdayBatch, sSundayBatch);
        }
    }
}